package com.example.user.customviewdemo.tabviewpager;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.example.user.customviewdemo.R;

import java.lang.reflect.Field;
import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

public class TabViewPagerActivity extends AppCompatActivity {

    @Bind(R.id.tab_view_pager)
    TabViewPager tabViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_view_pager);
        ButterKnife.bind(this);

        Field f = null;
        try {
            f = (Field) R.drawable.class.getDeclaredField("abc_ab_share_pack_mtrl_alpha");
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
        try {
            int j = f.getInt(R.drawable.class);
            Log.v("tag","j="+j);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        ArrayList<String> tabData = new ArrayList<>();
        ArrayList<Fragment> data = new ArrayList<>();
        for (int i = 0;i<5;i++){
            data.add(TabViewPagerFragment.newInstance("第"+i+"项",null));
            tabData.add("第" + i + "项");
        }
        tabViewPager.setTabs(tabData);
        tabViewPager.setFragments(data);
    }

}
